VERSION 5.00
Object = "{76DA8CE9-E736-47FC-B43F-82650E2EFBAF}#1.0#0"; "oControls.ocx"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmSec_Role 
   BackColor       =   &H00FFFFFF&
   BorderStyle     =   0  'None
   Caption         =   "User Role"
   ClientHeight    =   6750
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   10080
   FillColor       =   &H00FDEAE1&
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6750
   ScaleWidth      =   10080
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows Default
   Tag             =   "Settings"
   Begin oControls.oTab tabMain 
      Height          =   6585
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   10035
      _ExtentX        =   17701
      _ExtentY        =   11615
      TabCount        =   2
      TabCaption(0)   =   "            MAIN            "
      TabContCtrlCnt(0)=   1
      Tab(0)ContCtrlCap(1)=   "frmContainer"
      TabCaption(1)   =   "            LIST            "
      TabContCtrlCnt(1)=   1
      Tab(1)ContCtrlCap(1)=   "oFrames2"
      TabStyle        =   1
      TabTheme        =   1
      ActiveTabBackStartColor=   16514555
      ActiveTabBackEndColor=   16514555
      InActiveTabBackStartColor=   16777215
      InActiveTabBackEndColor=   15397104
      BeginProperty ActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty InActiveTabFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      OuterBorderColor=   10198161
      DisabledTabBackColor=   -2147483633
      DisabledTabForeColor=   10526880
      XRadius         =   15
      YRadius         =   15
      Begin oControls.oFrames oFrames2 
         Height          =   6285
         Left            =   -74985
         Tag             =   "."
         Top             =   300
         Width           =   10020
         _ExtentX        =   17674
         _ExtentY        =   11086
         FrameColor      =   16777215
         FillColor       =   16640737
         RoundedCorner   =   0   'False
         Caption         =   "List of Quotations"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Picture         =   "frmSec_Role.frx":0000
         Begin MSDataGridLib.DataGrid dtgList 
            Height          =   5865
            Left            =   0
            TabIndex        =   3
            Tag             =   "."
            Top             =   420
            Width           =   10020
            _ExtentX        =   17674
            _ExtentY        =   10345
            _Version        =   393216
            AllowUpdate     =   0   'False
            BackColor       =   16777215
            HeadLines       =   1
            RowHeight       =   15
            FormatLocked    =   -1  'True
            BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ColumnCount     =   2
            BeginProperty Column00 
               DataField       =   "cUserID"
               Caption         =   "User ID"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            BeginProperty Column01 
               DataField       =   "cName"
               Caption         =   "Name"
               BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                  Type            =   0
                  Format          =   ""
                  HaveTrueFalseNull=   0
                  FirstDayOfWeek  =   0
                  FirstWeekOfYear =   0
                  LCID            =   1033
                  SubFormatType   =   0
               EndProperty
            EndProperty
            SplitCount      =   1
            BeginProperty Split0 
               BeginProperty Column00 
               EndProperty
               BeginProperty Column01 
                  ColumnWidth     =   4199.811
               EndProperty
            EndProperty
         End
      End
      Begin oControls.oFrames frmContainer 
         Height          =   6285
         Left            =   0
         Top             =   300
         Width           =   10035
         _ExtentX        =   17701
         _ExtentY        =   11086
         FrameColor      =   16640737
         BackColor       =   16640737
         FillColor       =   16777215
         RoundedCorner   =   0   'False
         Caption         =   "Information"
         Alignment       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Picture         =   "frmSec_Role.frx":0A12
         Begin oControls.oFrames oFrames1 
            Height          =   4905
            Left            =   2895
            Top             =   1290
            Width           =   1080
            _ExtentX        =   1905
            _ExtentY        =   8652
            FrameColor      =   12829635
            FillColor       =   16777215
            Style           =   0
            RoundedCorner   =   0   'False
            Caption         =   ""
            TextColor       =   13579779
            Alignment       =   0
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Begin oControls.oFrames oFrames3 
               Height          =   2415
               Left            =   30
               Top             =   2340
               Width           =   1005
               _ExtentX        =   1773
               _ExtentY        =   4260
               FrameColor      =   12829635
               FillColor       =   16777215
               Style           =   0
               RoundedCorner   =   0   'False
               Caption         =   ""
               TextColor       =   13579779
               Alignment       =   0
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Begin oControls.oCheckBox oCheckBox2 
                  Height          =   210
                  Left            =   60
                  TabIndex        =   12
                  Top             =   105
                  Width           =   915
                  _ExtentX        =   1614
                  _ExtentY        =   370
                  BackColor       =   16777215
                  ForeColor       =   0
                  BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                     Name            =   "Tahoma"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Caption         =   "New"
               End
               Begin oControls.oCheckBox oCheckBox3 
                  Height          =   210
                  Left            =   60
                  TabIndex        =   13
                  Top             =   360
                  Width           =   915
                  _ExtentX        =   1614
                  _ExtentY        =   370
                  BackColor       =   16777215
                  ForeColor       =   0
                  BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                     Name            =   "Tahoma"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Caption         =   "Edit"
               End
               Begin oControls.oCheckBox oCheckBox4 
                  Height          =   210
                  Left            =   60
                  TabIndex        =   14
                  Top             =   600
                  Width           =   915
                  _ExtentX        =   1614
                  _ExtentY        =   370
                  BackColor       =   16777215
                  ForeColor       =   0
                  BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                     Name            =   "Tahoma"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Caption         =   "Delete"
               End
               Begin oControls.oCheckBox oCheckBox5 
                  Height          =   210
                  Left            =   60
                  TabIndex        =   15
                  Top             =   855
                  Width           =   915
                  _ExtentX        =   1614
                  _ExtentY        =   370
                  BackColor       =   16777215
                  ForeColor       =   0
                  BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                     Name            =   "Tahoma"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Caption         =   "Save"
               End
               Begin oControls.oCheckBox oCheckBox7 
                  Height          =   210
                  Left            =   60
                  TabIndex        =   16
                  Top             =   1110
                  Width           =   915
                  _ExtentX        =   1614
                  _ExtentY        =   370
                  BackColor       =   16777215
                  ForeColor       =   0
                  BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                     Name            =   "Tahoma"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Caption         =   "Find"
               End
               Begin oControls.oCheckBox oCheckBox8 
                  Height          =   210
                  Left            =   60
                  TabIndex        =   17
                  Top             =   1350
                  Width           =   915
                  _ExtentX        =   1614
                  _ExtentY        =   370
                  BackColor       =   16777215
                  ForeColor       =   0
                  BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                     Name            =   "Tahoma"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Caption         =   "Print"
               End
               Begin oControls.oCheckBox oCheckBox16 
                  Height          =   210
                  Left            =   60
                  TabIndex        =   18
                  Top             =   1605
                  Width           =   915
                  _ExtentX        =   1614
                  _ExtentY        =   370
                  BackColor       =   16777215
                  ForeColor       =   0
                  BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                     Name            =   "Tahoma"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Caption         =   "Approve"
               End
               Begin oControls.oCheckBox oCheckBox17 
                  Height          =   210
                  Left            =   60
                  TabIndex        =   19
                  Top             =   1860
                  Width           =   915
                  _ExtentX        =   1614
                  _ExtentY        =   370
                  BackColor       =   16777215
                  ForeColor       =   0
                  BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                     Name            =   "Tahoma"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Caption         =   "Reject"
               End
               Begin oControls.oCheckBox oCheckBox18 
                  Height          =   210
                  Left            =   60
                  TabIndex        =   20
                  Top             =   2115
                  Width           =   915
                  _ExtentX        =   1614
                  _ExtentY        =   370
                  BackColor       =   16777215
                  ForeColor       =   0
                  BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                     Name            =   "Tahoma"
                     Size            =   8.25
                     Charset         =   0
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Caption         =   "Untag"
               End
            End
            Begin oControls.oCheckBox oCheckBox1 
               Height          =   210
               Left            =   105
               TabIndex        =   11
               Top             =   2040
               Width           =   915
               _ExtentX        =   1614
               _ExtentY        =   370
               BackColor       =   16777215
               ForeColor       =   0
               BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "Tahoma"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   400
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               Caption         =   "All"
            End
            Begin oControls.oCommandButton oCommandButton1 
               Height          =   330
               Left            =   75
               TabIndex        =   7
               Top             =   105
               Width           =   915
               _ExtentX        =   1614
               _ExtentY        =   582
               BTYPE           =   5
               TX              =   ">>"
               ENAB            =   -1  'True
               BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               COLTYPE         =   1
               FOCUSR          =   -1  'True
               BCOL            =   16030833
               BCOLO           =   16030833
               FCOL            =   0
               FCOLO           =   0
               MCOL            =   16030833
               MPTR            =   1
               MICON           =   "frmSec_Role.frx":1424
               UMCOL           =   -1  'True
               SOFT            =   0   'False
               PICPOS          =   0
               NGREY           =   0   'False
               FX              =   0
               HAND            =   0   'False
               CHECK           =   0   'False
               VALUE           =   0   'False
            End
            Begin oControls.oCommandButton oCommandButton2 
               Height          =   330
               Left            =   75
               TabIndex        =   8
               Top             =   450
               Width           =   915
               _ExtentX        =   1614
               _ExtentY        =   582
               BTYPE           =   5
               TX              =   ">"
               ENAB            =   -1  'True
               BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               COLTYPE         =   1
               FOCUSR          =   -1  'True
               BCOL            =   15790320
               BCOLO           =   15790320
               FCOL            =   0
               FCOLO           =   0
               MCOL            =   12632256
               MPTR            =   1
               MICON           =   "frmSec_Role.frx":1440
               UMCOL           =   -1  'True
               SOFT            =   0   'False
               PICPOS          =   0
               NGREY           =   0   'False
               FX              =   0
               HAND            =   0   'False
               CHECK           =   0   'False
               VALUE           =   0   'False
            End
            Begin oControls.oCommandButton oCommandButton3 
               Height          =   330
               Left            =   75
               TabIndex        =   9
               Top             =   795
               Width           =   915
               _ExtentX        =   1614
               _ExtentY        =   582
               BTYPE           =   5
               TX              =   "<"
               ENAB            =   -1  'True
               BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               COLTYPE         =   1
               FOCUSR          =   -1  'True
               BCOL            =   15790320
               BCOLO           =   15790320
               FCOL            =   0
               FCOLO           =   0
               MCOL            =   12632256
               MPTR            =   1
               MICON           =   "frmSec_Role.frx":145C
               UMCOL           =   -1  'True
               SOFT            =   0   'False
               PICPOS          =   0
               NGREY           =   0   'False
               FX              =   0
               HAND            =   0   'False
               CHECK           =   0   'False
               VALUE           =   0   'False
            End
            Begin oControls.oCommandButton oCommandButton4 
               Height          =   330
               Left            =   75
               TabIndex        =   10
               Top             =   1140
               Width           =   915
               _ExtentX        =   1614
               _ExtentY        =   582
               BTYPE           =   5
               TX              =   "<<"
               ENAB            =   -1  'True
               BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
                  Name            =   "MS Sans Serif"
                  Size            =   8.25
                  Charset         =   0
                  Weight          =   700
                  Underline       =   0   'False
                  Italic          =   0   'False
                  Strikethrough   =   0   'False
               EndProperty
               COLTYPE         =   1
               FOCUSR          =   -1  'True
               BCOL            =   15790320
               BCOLO           =   15790320
               FCOL            =   0
               FCOLO           =   0
               MCOL            =   12632256
               MPTR            =   1
               MICON           =   "frmSec_Role.frx":1478
               UMCOL           =   -1  'True
               SOFT            =   0   'False
               PICPOS          =   0
               NGREY           =   0   'False
               FX              =   0
               HAND            =   0   'False
               CHECK           =   0   'False
               VALUE           =   0   'False
            End
         End
         Begin MSComctlLib.ListView lvwModules 
            Height          =   4905
            Left            =   120
            TabIndex        =   4
            Top             =   1290
            Width           =   2730
            _ExtentX        =   4815
            _ExtentY        =   8652
            View            =   3
            LabelEdit       =   1
            LabelWrap       =   -1  'True
            HideSelection   =   -1  'True
            FullRowSelect   =   -1  'True
            GridLines       =   -1  'True
            HoverSelection  =   -1  'True
            _Version        =   393217
            ForeColor       =   -2147483640
            BackColor       =   -2147483643
            BorderStyle     =   1
            Appearance      =   0
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            NumItems        =   0
         End
         Begin oControls.oTextBox txtcRoleID 
            Height          =   285
            Left            =   120
            TabIndex        =   1
            Tag             =   "1"
            Top             =   555
            Width           =   3090
            _ExtentX        =   5239
            _ExtentY        =   503
            BackColor       =   14745599
            LabelBackColor  =   16777215
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Role ID"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelForeColor  =   16777215
            TextBoxWidth    =   1530
         End
         Begin oControls.oTextBox txtcModuleID 
            Height          =   285
            Left            =   3225
            TabIndex        =   2
            Top             =   555
            Width           =   2820
            _ExtentX        =   4868
            _ExtentY        =   503
            BackColor       =   14745599
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            AllCaps         =   -1  'True
            Mandatory       =   -1  'True
            Label           =   "Name"
            BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            LabelWidth      =   0
            TextBoxWidth    =   2760
         End
         Begin MSComctlLib.ListView lvwAccess 
            Height          =   4905
            Left            =   4020
            TabIndex        =   5
            Top             =   1290
            Width           =   5835
            _ExtentX        =   10292
            _ExtentY        =   8652
            View            =   3
            LabelEdit       =   1
            LabelWrap       =   -1  'True
            HideSelection   =   -1  'True
            FullRowSelect   =   -1  'True
            GridLines       =   -1  'True
            HoverSelection  =   -1  'True
            _Version        =   393217
            ForeColor       =   -2147483640
            BackColor       =   -2147483643
            BorderStyle     =   1
            Appearance      =   0
            BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            NumItems        =   0
         End
         Begin VB.Label Label1 
            Alignment       =   2  'Center
            BackColor       =   &H00000000&
            Caption         =   "Edit Access Level"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H00FFFFFF&
            Height          =   225
            Left            =   4020
            TabIndex        =   6
            Top             =   1050
            Width           =   5820
         End
      End
   End
End
Attribute VB_Name = "frmSec_Role"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'----------------------------------------------------------------------------------------------------------------------------------
'Standard Programming Format----------------------------------------------------------------------------------------
'----------------------------------------------------------------------------------------------------------------------------------

Dim cnHeader As New Connection
Dim cnDetail As New Connection
Dim rsHeader As New Recordset
Dim rsDetail As New Recordset
Dim tmpObj As Object

Dim sBit() As Boolean
Dim vBookmark As Variant

Public mode As eMode

Private Sub DataOtherBind()
    Set dtgList.DataSource = rsHeader
End Sub

Public Sub TBNew()
    mode = AddEditNew
    
    If rsHeader.State <> 1 Then
        TranConnect cnHeader
        TranConnect cnDetail
        TranRecordset Mid$(Me.Name, 4, Len(Me.Name)), rsHeader, cnHeader, "1=0"
        TranRecordset Mid$(Me.Name, 4, Len(Me.Name)) & "_D", rsDetail, cnDetail
        
        DataSourceBind rsHeader, Me
        DataFieldBind rsHeader, Me
        DataOtherBind
    Else
        vBookmark = rsHeader.Bookmark
    End If
    
    ControlObjects Me
    BitEnable sBit, Me, oMDI
    
    rsHeader.AddNew
    
    FilterRecord "cTranNo", rsHeader!cUserID, rsDetail
    
    RSDisconnectCN rsHeader
    RSDisconnectCN rsDetail
    
End Sub

Public Sub TBEdit()
    mode = AddEditNew
    
    ControlObjects Me
    FilterRecord "cTranNo", rsHeader!cUserID, rsDetail
    
    RSDisconnectCN rsHeader
    RSDisconnectCN rsDetail
    
    BitEnable sBit, Me, oMDI
End Sub

Public Sub TBDelete()
    On Error GoTo ErrHandler
    
    Dim sID As String
    
    RSConnectCN rsHeader, cnHeader
    RSConnectCN rsDetail, cnDetail
    
    sID = rsHeader!cTranNo
    
    If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, ProjectVersion) = vbNo Then Exit Sub
    FilterRecord "cTranNo", rsHeader!cUserID, rsDetail
    If rsDetail.RecordCount <> 0 Then
        rsDetail.MoveFirst
        Do Until rsDetail.RecordCount = 0
            rsDetail.Delete adAffectCurrent
            If rsDetail.RecordCount <> 0 Then rsDetail.MoveFirst
        Loop
    End If
    
    AuditLog Mid$(Me.Name, 4, Len(Me.Name)), Trim(txtcRoleID), "Deleted"
    rsHeader.Delete adAffectCurrent
    
    rsDetail.UpdateBatch adAffectAll
    rsHeader.UpdateBatch adAffectAll
    
    TBPrevious
    mode = Normal
    
    If rsHeader.RecordCount = 0 Then
        ClearDataValue Me
    Else
        vBookmark = rsHeader.Bookmark
        DataUnbind Me
        DataSourceBind rsHeader, Me
        DataFieldBind rsHeader, Me
        rsHeader.Bookmark = vBookmark
    End If
    
    BitEnable sBit, Me, oMDI

ErrHandler:
    If Err.Number = -2147217885 Then
        Resume Next
    ElseIf Err.Number = -2147217864 Or Err.Number = -2147217887 Then
        cn.Execute "DELETE " & Mid$(Me.Name, 4, Len(Me.Name)) & "_D WHERE cTranNo = '" & sID & "' AND cCompID = '" & sCompanyID & "'"
        cn.Execute "DELETE " & Mid$(Me.Name, 4, Len(Me.Name)) & " WHERE cTranNo = '" & sID & "' AND cCompID = '" & sCompanyID & "'"
        Resume Next
    End If

End Sub

Public Sub TBSave()
    On Error GoTo ErrHandler
    Dim lNew As Boolean
    
    mode = Find
    If rsHeader.Status = adRecNew Then lNew = True
    If MandatoryOK(Me) = False Then Exit Sub
    
    RSConnectCN rsHeader, cnHeader
    RSConnectCN rsDetail, cnDetail

    cn.BeginTrans
    cnHeader.BeginTrans
    cnDetail.BeginTrans
    
    rsHeader.UpdateBatch adAffectAll
    rsDetail.UpdateBatch adAffectAll
   
    cn.CommitTrans
    cnHeader.CommitTrans
    cnDetail.CommitTrans
    
    Set FrmName = Me
    mode = Normal
    ControlObjects Me
    
    AuditLog Mid$(Me.Name, 4, Len(Me.Name)), rsHeader!cTranNo, IIf(lNew, "Add Record", "Modify Record")
    MsgBox "Record/s successfully saved.", vbInformation, ProjectVersion
    
    BitEnable sBit, Me, oMDI
ErrHandler:
    If Err.Number = -2147168237 Then
        rsHeader.CancelBatch adAffectCurrent
        If rsDetail.RecordCount <> 0 Then rsDetail.CancelBatch adAffectCurrent
        cnHeader.RollbackTrans
        cnDetail.RollbackTrans
    ElseIf Err.Number <> 0 Then
        MsgBox Err.Description, vbCritical, ProjectVersion
    End If
End Sub

Public Sub TBUndo()
    mode = Normal
    
    FilterRecord "cTranNo", rsHeader!cUserID, rsDetail
    If rsHeader.Status = adRecNew Then
        rsDetail.CancelBatch adAffectAll
        rsHeader.CancelUpdate
    Else
        rsHeader.CancelBatch adAffectCurrent
        rsDetail.CancelBatch adAffectAll
    End If
        
    DataUnbind Me
    If rsHeader.RecordCount = 0 Then
        ClearDataValue Me
        rsHeader.Close
        rsDetail.Close
        mode = Find
    Else
        rsHeader.Bookmark = vBookmark
        DataSourceBind rsHeader, Me
        DataFieldBind rsHeader, Me
        DataOtherBind
    End If
    
    ControlObjects Me
    BitEnable sBit, Me, oMDI
End Sub

Public Sub TBFind()
    Dim sCond As String
    
    If mode = Find Then
        mode = Normal
        
        sCond = GetSearchString(Me)
        TranConnect cnHeader
        TranConnect cnDetail
        TranRecordset Mid$(Me.Name, 4, Len(Me.Name)), rsHeader, cnHeader, sCond
        TranRecordset Mid$(Me.Name, 4, Len(Me.Name)) & "_D", rsDetail, cnDetail, IIf(sCond <> "", " cTranNo in (SELECT cTranNo FROM " & Mid$(Me.Name, 4, Len(Me.Name)) & " WHERE " & sCond & ")", "")
        FilterRecord "cUserID", rsHeader!cUserID, rsDetail
        
        DataSourceBind rsHeader, Me
        DataFieldBind rsHeader, Me
        DataOtherBind
        
        RSDisconnectCN rsHeader
        RSDisconnectCN rsDetail
               
    Else
        mode = Find
        rsHeader.Close
        rsDetail.Close
        DataUnbind Me
        ClearDataValue Me
    End If
    
    ControlObjects Me
    BitEnable sBit, Me, oMDI
End Sub

Public Sub TBPrint()
    PrintReceipt Mid$(Me.Name, 4, Len(Me.Name)), rsHeader!cTranNo
End Sub

Public Sub TBFirst()
    FirstRecord rsHeader
End Sub

Public Sub TBPrevious()
    PreviousRecord rsHeader
End Sub

Public Sub TBNext()
    NextRecord rsHeader
End Sub

Public Sub TBLast()
    LastRecord rsHeader
End Sub

Public Sub TBNewLine()
    
End Sub

Public Sub TBDeleteLine()

End Sub

Public Sub TBApprove()

End Sub

Public Sub TBReject()

End Sub

Public Sub TBUntag()

End Sub

Public Sub TBClose()
    On Error Resume Next
    Set FrmName = Nothing
    Unload Me
End Sub

Public Sub TBReload()
    Me.ZOrder
    Set FrmName = Me
    BitEnable sBit, Me, oMDI
End Sub

Private Sub dtgDetails_ButtonClick(ByVal ColIndex As Integer)
    Select Case ColIndex
        Case 2
            LoadPicker "Role"
            rsDetail!cUserID = rsHeader!cUserID
            rsDetail!cRoleID = pckCode
    End Select
End Sub

Private Sub dtgDetails_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If mode <> AddEditNew Then Exit Sub
    If Button = 2 Then
        PopupMenu oMDI.mnuPopupDetail
    End If
End Sub

Private Sub Form_Click()
    TBReload
End Sub

Private Sub Form_Load()
    GetAccessLevel oMDI.tbMain, sUserRole, Me.Name, sBit()
    mode = Find
    
    ApplyFrameTheme frmContainer, Me
    BitEnable sBit, Me, oMDI
End Sub


